cmake_minimum_required(VERSION 3.10.2)
project(LDBProj)

set(CMAKE_CXX_STANDARD 17)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
# place binaries and libraries according to GNU standards
include(GNUInstallDirs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
add_subdirectory(utils_native)
add_subdirectory(mock)
add_subdirectory(relational_store)
add_subdirectory(data_share)
add_subdirectory(kv_store)
add_subdirectory(preferences)
add_subdirectory(data_object)
add_subdirectory(datamgr_service)

set(CMAKE_CXX_FLAGS "-std=c++1y -fno-rtti -fvisibility=default -D_GNU_SOURCE")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -fPIC -fpic -ffunction-sections -D_GLIBC_MOCK")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed -ldl")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare -Wimplicit-fallthrough")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wformat=0")

add_subdirectory(googletest)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utils_native/base/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/utils_native/safwk/native/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mock/innerkits/ipc/ipc_core/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mock/innerkits/ipc/ipc_single/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mock/innerkits/ipc/libdbinder/include)

set(MAIN_BINARY ${PROJECT_NAME})
set(links secure mock relational_store data_share preferences jsoncpp crypto distributeddb data_object app adapter svcFwk kvdb service)
add_executable(${MAIN_BINARY} dllmain.cpp)
target_link_libraries(${MAIN_BINARY} ${links})

# add test module
enable_testing()
add_subdirectory(test)
